package com.dingshi.security.entity;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.dingshi.security.R;

public class SyncButton extends LinearLayout {
	private ImageView iv;
	private TextView tv;

	private ImageView smallIv;
	private View lInflater;

	public SyncButton(Context context) {
		super(context);
		initialUI(context);
	}

	public SyncButton(Context context, AttributeSet attrs) {
		super(context, attrs);
		initialUI(context);
	}

	public SyncButton(Context context, int imageId, String text) {
		super(context);
		initialUI(context);

		setImageResource(imageId);
		setTextViewText(text);
	}

	private void initialUI(Context context) {
		lInflater = LayoutInflater.from(context).inflate(R.layout.syncbutton,
				this, true);
		iv = (ImageView) findViewById(R.id.textprogress_image);
		tv = (TextView) findViewById(R.id.textprogress_text);
		this.setClickable(true);
		this.setBackgroundResource(R.drawable.main_selector);
	}

	/**
	 * 设置图片资源
	 */
	public void setImageResource(int resId) {
		iv.setImageResource(resId);
	}

	/**
	 * 设置显示的文字
	 */
	public void setTextViewText(CharSequence text) {
		tv.setText(text);
	}

	public void setAlertIcon(int resId) {
		smallIv.setImageResource(resId);
		smallIv.setVisibility(View.VISIBLE);
	}

	public void setAlertIconGone() {
		smallIv.setVisibility(View.GONE);
	}

}
